Skip to content

Fix filter to use translated labels for enums implementing TranslatableInterface#7576

Open
lacatoire wants to merge 3 commits intoEasyCorp:5.xfrom
lacatoire:fix/filter-translatable-backed-enum
Open

Fix filter to use translated labels for enums implementing TranslatableInterface#7576
lacatoire wants to merge 3 commits intoEasyCorp:5.xfrom
lacatoire:fix/filter-translatable-backed-enum

Conversation

@lacatoire
Copy link
Copy Markdown
Contributor

When a backed enum implements TranslatableInterface and is passed to ChoiceFilter::setTranslatableChoices(MyEnum::cases()), the filter submitted the list indices (0, 1, 2, ...) instead of the enum values, so no row ever matched.

The fix detects a list of UnitEnum / BackedEnum cases and uses their backing values (or names) as submitted values, keeping the enum instances as labels so TranslatableInterface keeps working.

Fixes #7571

@Seb33300
Copy link
Copy Markdown
Contributor

Maybe related to #7243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Filter] Filtering translatable backed enums is broken

2 participants